import 'package:flutter/material.dart';

class CommonFormItem extends StatelessWidget {
  final String label;
  final Widget Function(BuildContext context) contentBuild;

  final Widget suffix;
  final String suffixText;

  final String hintText;
  final ValueChanged onchanged;
  final TextEditingController controller;

  const CommonFormItem(
      {Key key,
      this.label,
      this.contentBuild,
      this.suffix,
      this.suffixText,
      this.hintText,
      this.onchanged,
      this.controller})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 14.0, right: 14.0),
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  //获取主体颜色
                  width: 1.0,
                  color: Theme.of(context).dividerColor))),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            width: 100.0,
            child: Text(label,
                style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w400)),
          ),
          Expanded(
            child: contentBuild != null
                ? contentBuild(context)
                : TextField(
                    controller: controller,
                    decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText: hintText,
                    ),
                  ),
          ),
          if (suffix != null) suffix,
          if (suffix == null && suffixText != null) Text(suffixText),
          // Container(
          //   width: 100.0,
          //   child: Text(suffixText),
          // ),
        ],
      ),
    );
  }
}
